package com.service.khqy;

import com.bpms.common.CommonUtil;
import com.bpms.common.JdbcWorker;
import com.bpms.common.VO;
import com.bpms.common.VOList;
import com.bpms.esb.IService;

public class Getavailableaccounts implements IService {

	public static void main(String[] args) throws Exception{
		VO vo = new VO();
		vo.setAttr("CARDID", "123456");
		vo.setAttr("ACCOUNTTYPE", "1");
		vo.setAttr("PASSWORD", "123");
		VO result = new Getavailableaccounts().exec(vo);
		CommonUtil.debug(result);
	}
	
	public VO exec(VO args) {
		String sql = "select a.name,a.iccard,a.idcard,a.idtype,a.createdate,a.available,a.address,a.mobile,an.account,an.fullname,an.bank,an.available " +
		"from accountinfo a,accountno an where a.id=an.accountid and a.available='1' and an.available='1' and ";
		JdbcWorker j=null;
		VO vo = new VO();
		try{
			j = new JdbcWorker();
			
			String CARDID=args.getAttr("CARDID");
			String ACCOUNTTYPE = args.getAttr("ACCOUNTTYPE");
			String PASSWORD = args.getAttr("PASSWORD");
			if(PASSWORD.trim().length()!=0)
				sql += "a.password='" + PASSWORD +"' and ";
			
			if("1".equals(ACCOUNTTYPE)){ //iccard
				sql += "a.iccard='" + CARDID + "'";
			}else if("3".equals(ACCOUNTTYPE)){ //idcard
				sql += "a.idcard='" + CARDID + "'";
			}else{
				CommonUtil.debug("Getavailableaccounts  error ：不支持的帐户类型");
				return null;
			}
			
			VOList volist=j.readAll(new VO(), sql);
			vo.setObj("volist", volist);
			return vo;
		}catch(Exception e){
			CommonUtil.debug("Savebillimage  error", e);
			return null;
		}
	}

}
